package com.drop.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Goods entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "goods", catalog = "feature_mall")
public class Goods implements java.io.Serializable {

	// Fields

	private Integer goodsId;
	private Shop shop;
	private District district;
	private Goodstype goodstype;
	private String goodsName;
	private String goodsImg;
	private String goodsContent;
	private Float price;
	private Integer stock;
	private Integer salesNum;
	private Set<Collection> collections = new HashSet<Collection>(0);
	private Set<Cart> carts = new HashSet<Cart>(0);
	private Set<Childorder> childorders = new HashSet<Childorder>(0);

	// Constructors

	/** default constructor */
	public Goods() {
	}

	/** full constructor */
	public Goods(Shop shop, District district, Goodstype goodstype,
			String goodsName, String goodsImg, String goodsContent,
			Float price, Integer stock, Integer salesNum,
			Set<Collection> collections, Set<Cart> carts,
			Set<Childorder> childorders) {
		this.shop = shop;
		this.district = district;
		this.goodstype = goodstype;
		this.goodsName = goodsName;
		this.goodsImg = goodsImg;
		this.goodsContent = goodsContent;
		this.price = price;
		this.stock = stock;
		this.salesNum = salesNum;
		this.collections = collections;
		this.carts = carts;
		this.childorders = childorders;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "goodsId", unique = true, nullable = false)
	public Integer getGoodsId() {
		return this.goodsId;
	}

	public void setGoodsId(Integer goodsId) {
		this.goodsId = goodsId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "shopId")
	public Shop getShop() {
		return this.shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "districtId")
	public District getDistrict() {
		return this.district;
	}

	public void setDistrict(District district) {
		this.district = district;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "goodsTypeId")
	public Goodstype getGoodstype() {
		return this.goodstype;
	}

	public void setGoodstype(Goodstype goodstype) {
		this.goodstype = goodstype;
	}

	@Column(name = "goodsName", length = 45)
	public String getGoodsName() {
		return this.goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}

	@Column(name = "goodsImg", length = 45)
	public String getGoodsImg() {
		return this.goodsImg;
	}

	public void setGoodsImg(String goodsImg) {
		this.goodsImg = goodsImg;
	}

	@Column(name = "goodsContent")
	public String getGoodsContent() {
		return this.goodsContent;
	}

	public void setGoodsContent(String goodsContent) {
		this.goodsContent = goodsContent;
	}

	@Column(name = "price", precision = 12, scale = 0)
	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	@Column(name = "stock")
	public Integer getStock() {
		return this.stock;
	}

	public void setStock(Integer stock) {
		this.stock = stock;
	}

	@Column(name = "salesNum")
	public Integer getSalesNum() {
		return this.salesNum;
	}

	public void setSalesNum(Integer salesNum) {
		this.salesNum = salesNum;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "goods")
	public Set<Collection> getCollections() {
		return this.collections;
	}

	public void setCollections(Set<Collection> collections) {
		this.collections = collections;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "goods")
	public Set<Cart> getCarts() {
		return this.carts;
	}

	public void setCarts(Set<Cart> carts) {
		this.carts = carts;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "goods")
	public Set<Childorder> getChildorders() {
		return this.childorders;
	}

	public void setChildorders(Set<Childorder> childorders) {
		this.childorders = childorders;
	}


	@Override
	public String toString() {
		return "Goods{" +
				"goodsId=" + goodsId +
				", goodsName='" + goodsName + '\'' +
				", goodsImg='" + goodsImg + '\'' +
				", goodsContent='" + goodsContent + '\'' +
				", price=" + price +
				", stock=" + stock +
				", salesNum=" + salesNum +
				'}';
	}
}